//
// Created by Administrator on 2023/7/28.
//
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class Solution {
public:
    int maximizeSum(vector<int> &nums, int k) {
        int maxOfNums = *max_element(nums.begin(), nums.end());
        return (2 * maxOfNums + k - 1) * k / 2;
    }
};

int main() {
    Solution s;
    vector<int> nums{1, 2, 3, 4, 5};
    cout << s.maximizeSum(nums, 3) << endl;
}